package leetcode;

/**
 * Created with IntelliJ IDEA.
 * Description:141. 环形链表
 * User: 东莞呵呵
 * Date:2022-07-10
 * Time:10:41
 */
public class TestDemo {
    public boolean hasCycle(ListNode head) {
        ListNode fast=head;
        ListNode slow=head;
        while(fast!=null&&fast.next!=null&&fast.next.next!=null){
            fast=fast.next.next;
            slow=slow.next;
            if(fast==slow){
                return true;
            }
        }
        return false;
    }
}
